//----------------------------------------------------------------------------------------------------------------------
// Copyright (c) 2012 James Whitworth
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the \"Software\"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//----------------------------------------------------------------------------------------------------------------------



//----------------------------------------------------------------------------------------------------------------------
// Describes the base of all googletest tests for code generation
//----------------------------------------------------------------------------------------------------------------------
class TestBase extends Function
{
  suite = null

  constructor(_suite, _name, _flags = 0)
  {
    base.constructor(_name, _flags)

    suite = _suite
    return_type = NullParameter()
  }
  
  // overload base is_templated for handling CodeGenerator.kPointer
  //
  function is_templated()
  {
    return false
  }
  
  function is_specialisation()
  {
    return false
  }

  function has_header_data()
  {
    return false
  }

  function has_inline_data()
  {
    return false
  }

  function has_source_data()
  {
    return true
  }
  
  function write_name_definition(stream)
  {
    // base implementation of this should never be called
    //
    assert(false)
  }
  
  function write_parameters_definition(stream, file_type)
  {
    assert(typeof(suite) == "string")
    assert(suite.len() > 0)

    assert(typeof(name) == "string")
    assert(name.len() > 0)
    
    stream.write("(%s, %s)", suite, name)
  }

  function write_pre_definition(stream)
  {
    // nothing to do
  }

  function write_post_definition(stream)
  {
    // nothing to do
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Describes a googletest test for code generation
//----------------------------------------------------------------------------------------------------------------------
class Test extends TestBase
{
  constructor(_suite, _name, _flags = 0)
  {
    base.constructor(_suite, _name, _flags)
  }

  function write_name_definition(stream)
  {   
    stream.write("TEST")
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Describes a googletest test fixture for code generation
//----------------------------------------------------------------------------------------------------------------------
class TestFixture extends TestBase
{
  constructor(_suite, _name, _flags = 0)
  {
    base.constructor(_suite, _name, _flags)
  }

  function write_name_definition(stream)
  {
    stream.write("TEST_F")
  }
}